package com.test.uiapp2.tools;

import android.renderscript.ScriptIntrinsicYuvToRGB;
import android.util.Log;

import com.test.uiapp2.base.TestBase;
import com.test.uiapp2.element.Base.BaseElement;
import com.test.uiapp2.element.Compatible.CompatibleElement;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

import static junit.framework.TestCase.assertTrue;

public class test {
    public static final String JINGOS_TEAM= "https://github.com/JingOS-team/JingOS/issues";
    public static final String VIDEOPLAYER= "https://github.com/JingOS-team/videoplayer/issues";
    public static final String GITHUBURL= " https://github.com";


    public static  List<packages> getpackages(){
        List<packages> list=new ArrayList<>();
        try {
            Document document = Jsoup.connect("https://sj.qq.com/myapp/category.htm?orgame=1&categoryId=122").ignoreContentType(true).get();
            Elements select = document.select("div.app-info-desc");
            System.out.println(select.size()+"个");
            for (int i = 0; i < select.size(); i++) {
                String appname = document.select("div.app-info-desc").select("a.com-install-btn").get(i).attr("appname");
                String PackagesName = document.select("div.app-info-desc").select("a.com-install-btn").get(i).attr("apk");
                packages pa=new packages(appname,PackagesName);
                list.add(pa);
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
        return list;
    }

    public static void main(String[] args) {

        try {
            Document document = Jsoup.connect(test.JINGOS_TEAM).ignoreContentType(true).get();
            //JingOS-team
            Elements select = document.select("div.Box-row").select("div.d-flex").select("div.flex-auto");
            System.out.println(select.size());
            for (int i=0;i<select.size();i++){
                String text = select.select("a.Link--primary").get(i).text();
                String href = select.select("a.Link--primary").get(i).attr("href");
                Document desc_document = Jsoup.connect(test.GITHUBURL+href).ignoreContentType(true).get();
                String text1 = desc_document.select("tr.d-block").select("td.d-block").text();
                String the = text1.substring(0, text1.indexOf("The"));
                System.out.println(the);

            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


//    public static void main(String[] args) {
//        try {
//            Document document = Jsoup.connect("https://sj.qq.com/myapp/category.htm?orgame=1&categoryId=116").ignoreContentType(true).get();
//            System.out.println(document);
//            Elements select = document.select("div.app-info-desc");
//            System.out.println(select.size()+"个");
//            for (int i = 0; i <20; i++) {
//                String appname = document.select("div.app-info-desc").select("a.com-install-btn").get(i).attr("appname");
//                String PackagesName = document.select("div.app-info-desc").select("a.com-install-btn").get(i).attr("apk");
//                System.out.println(appname);
//            }
//            for (int i = 0; i <20; i++) {
//                String appname = document.select("div.app-info-desc").select("a.com-install-btn").get(i).attr("appname");
//                String PackagesName = document.select("div.app-info-desc").select("a.com-install-btn").get(i).attr("apk");
//                System.out.println(PackagesName);
//            }
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//    }
}
//        long l = System.currentTimeMillis();
//        SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
//        long l1 = Long.parseLong("1625130904086");
//        Date date = new Date(l1);
//        dateFormatter.format(date);
//         System.out.println(dateFormatter.format(date));


//            String url = "https://www.wandoujia.com/wdjweb/api/top/more?resourceType=0&page=1&ctoken=nHFrElx5O6jmzLtx-VpHuUCt";
//            Document document1 = Jsoup.connect(url).ignoreContentType(true).timeout(50000).get();
//            Elements select = document1.select("li").select("div").select("h2");
//            System.out.println(select.size());
//            for (int i = 0; i < select.size(); i++) {
//                String attr = select.select("a").get(i).attr("title");
//                String appname = attr.replace("\\\"", "");
//                System.out.println(appname);
//            }
//        try {
////            String url = "https://www.wandoujia.com/wdjweb/api/top/more?resourceType=0&page=9&ctoken=nHFrElx5O6jmzLtx-VpHuUCt";
//
//            String url = "https://www.wandoujia.com/category/5027";
//            Document document1 = Jsoup.connect(url).ignoreContentType(true).timeout(50000).get();
//            Elements select = document1.select("li").select("div").select("h2");
//            System.out.println(select.size());
//            for (int i = 0; i < select.size(); i++) {
//                String attr = select.select("a").get(i).attr("title");
//                String appname = attr.replace("\\\"", "");
//                System.out.println(appname);
//            }
//        } catch (IOException e) {
//            e.printStackTrace();
//        }


